package org.eenie.appseed.ui.bento.holder.base

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.blankj.utilcode.util.LogUtils
import com.yelp.android.bento.core.ComponentViewHolder

abstract class BaseBindingViewHolder<P, M, BD : ViewBinding> : ComponentViewHolder<P, M>() {

    lateinit var binding: BD

    override fun bind(presenter: P, item: M) {
        LogUtils.e(presenter, item)
        if (item != null) {
            convert(binding, item)
        }
    }

    override fun inflate(parent: ViewGroup): View {
        binding = providerBinding(LayoutInflater.from(parent.context))
        return binding.root
    }

    abstract fun providerBinding(inflater: LayoutInflater): BD
    abstract fun convert(binding: BD, item: M)


}